<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <title>1_字符串形式的ref</title>
</head>

<body>
  <!-- 准备好一个“容器” -->
  <div id="test"></div>

  <!-- 引入react核心库 -->
  <script type="text/javascript" src="./js/react.development.js"></script>
  <!-- 引入react-dom，用于支持react操作DOM -->
  <script type="text/javascript" src="./js/react-dom.development.js"></script>
  <!-- 引入babel，用于将jsx转为js -->
  <script type="text/javascript" src="./js/babel.min.js"></script>

  <script type="text/babel">
    class Login extends React.Component {
      submitFn = (event) => {
        event.preventDefault()
        const { ipt1, ipt2 } = this
        console.log(ipt1.value, ipt1.value)
      }

      render() {
        return (
          <div>
            <form onSubmit={this.submitFn}>
              <input type="text" ref={current => this.ipt1 = current} />
              <input type="text" ref={current => this.ipt2 = current} />
              <button>btn</button>
            </form>
          </div>
        )
      }
    }

    ReactDOM.render(<Login />, document.getElementById('test'))
  </script>
</body>

</html>